/* jshint -W024 */
import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store/index.js'
import CloudSystem from './cloudSystem.js'
const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
//公共模块路由
const SharingRouter = [{
    // 首页
    path: '/',
    name: '/home',
    // component: () => import('@/components/HelloWorld.vue')
    component: () => import('@/views/home.vue')
  }, { //学生考试场次页
    path: '/testSession',
    name: 'testSession',
    component: () =>
      import('@/views/operationMenu/testSession.vue'),
  }, { //裁判操作菜单
    path: '/operationMenu',
    name: 'operationMenu',
    component: () =>
      import('@/views/operationMenu/operationMenu.vue'),
  }, { //赛务管理
    path: '/saiWuManagement',
    name: "saiWuManagement",
    component: () =>
      import('@/views/saiWuManagement/index.vue'),
  }, { //开封题库
    path: '/openQuestionBank',
    name: "openQuestionBank",
    component: () =>
      import('@/views/openQuestionBank/openQuestionBank.vue'),
  }, { //实时监控
    path: '/eventMonitoring',
    name: "eventMonitoring",
    component: () =>
      import('@/views/eventMonitoring/index.vue'),
  }, { //成绩统计
    path: '/eventResultsStatistical',
    name: "eventResultsStatistical",
    component: () =>
      import('@/views/eventResultsStatistical/index.vue'),
  },
  {
    path: '/student',
    name: '/student',
    component: () =>
      import('@/views/student/root.vue'),
    children: [
      ...CloudSystem
    ],
  },
];

// const CloudSystemRouter = [
//   // {
//   //   path: '/student/customerDetails/index',
//   //   name: '客户详情',
//   //   component: () => import('@/views/student/customerDetails/index.vue')
//   // },
//   {
//     path: '/customerDetails',
//     class: 'customerDetails',
//     name: '客户详情',
//     component: () =>
//       import( /* webpackChunkName: "taxation" */ '@/views/student/customerDetails/index.vue'),
//     redirect: '/student/customerDetails/customerDetails',
//     children: [{
//         path: '/student/customerDetails/customerDetails', //三方协议缴款
//         component: () =>
//           import( /* webpackChunkName: "taxation" */ '@/views/student/customerDetails/customerDetails.vue'),
//         name: '客户详情'
//       },
//       {
//         path: '/student/customerDetails/projectDetails', //历史查询
//         component: () =>
//           import( /* webpackChunkName: "taxation" */ '@/views/student/customerDetails/projectDetails.vue'),
//         name: '项目详情'
//       }
//     ]
//   },
// ];
const StudentRouter = [{
    path: '/student',
    name: 'student',
    component: () => import('@/views/student/index.vue')
  },
  {
    path: '/student/trainingCenter',
    name: 'trainingCenter',
    component: () => import('@/views/student/trainingCenter.vue')
  },
  {
    path: '/student/questions',
    name: 'questions',
    component: () => import('@/views/student/questions.vue')
  }
];

const TeacherRouter = [{
	  path: '/teacher',
	  component: () => import('@/views/Teacher/teacherMain.vue'),
	  children:[
	  	{
	  		path:'/teacher',
	  		component:()=>import('@/views/Teacher/Tmain.vue'),
	  	},
		{
			path:'/task',
			component:()=>import('@/views/Teacher/taskCenter.vue'),
		},
		{
			path:'/studentManage',
			component:()=>import('@/views/Teacher/studentManage.vue'),
		},
		{
			path:'/Policy',
			component:()=>import('@/views/Teacher/Policy.vue'),
		},
	  ]
	  
	},
]

// const originalPush = Router.prototype.push
// //修改原型对象中的push方法
// Router.prototype.push = function push(location) {
//     return originalPush.call(this, location).catch(err => err)

Vue.use(Router);
const router = new Router({
  // mode: 'history',
  routes: [...SharingRouter, ...StudentRouter,...CloudSystem,...TeacherRouter],
  // routes: [...SharingRouter, ...StudentRouter],
  // routes: [...TeacherRouter],
})

// router.beforeEach((to, from, next) => {
// console.log('to',to)
// let userInfo = JSON.parse(sessionStorage.getItem('UserInfo'));
// if (!userInfo && to.path !== '/Login' && to.path !== '/Regist') { // 用户id 不存在的时候跳转到登录
//     next('/Login');
//     return;
// }
// if (sessionStorage.getItem('accessToken')) { // 通过vuex state获取当前的token是否存在
//     if(to.path=='/examList'||to.path=='/user/examCase'){
//         // console.log("***********",userInfo)
//         if(userInfo.type==6){
//             next();
//             return;
//         }else{
//             next('/new_index');
//             return;
//         }
//     }else{
//         next();
//         return;
//     }
// } else {

// }
// next();
// })

export default router;
